package robot;

import lejos.nxt.LCD;

class CommandThread extends Thread {
	
	//name the thread in the constructor
    public CommandThread(String str) {
    	super(str);
    }
    
    //the thing for the thread to do
    public void run() {
		//connect to bluetooth code moved to connection class 
		OnBoard.getConnection().connect();

		int n=0; //holds the incoming command
		
		//THREAD 2
		//look for the command
		while (OnBoard.keepItRunning){
			try {
				n= OnBoard.getConnection().getNextCommand();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			
			if (n!=-1){
				LCD.drawInt(n,7,0,1);
				OnBoard.getRobot().execute(n);
				System.out.println("N : "+n);
			}
		}
		//END THREAD 2
    	
    }
}